package com.itheima.mapper.sms;



import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.vo.domain.TableDataInfo;
import com.itheima.vo.pojo.SmsCoupon;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SmsCouponMapper extends BaseMapper<SmsCoupon> {

    //优惠券的修改
    @Update("update sms_coupon\n" +
            "    set type = #{type},\n" +
            "      name = #{name},\n" +
            "      platform = #{platform},\n" +
            "      count = #{count},\n" +
            "      amount = #{amount},\n" +
            "      per_limit = #{perLimit},\n" +
            "      min_point = #{minPoint},\n" +
            "      start_time = #{startTime},\n" +
            "      end_time = #{endTime},\n" +
            "      use_type = #{useType},\n" +
            "      note = #{note},\n" +
            "      publish_count = #{publishCount},\n" +
            "      use_count = #{useCount},\n" +
            "      receive_count = #{receiveCount},\n" +
            "      enable_time = #{enableTime},\n" +
            "      code = #{code},\n" +
            "      member_level = #{memberLevel}\n" +
            "    where id = #{id}")
    void update(SmsCoupon smsCoupon);


    /*//优惠券的分页查询
    public default Page<SmsCoupon> page(Integer pageNum,Integer pageSize,Integer type,String name){

        Page<SmsCoupon> pageInfo = new Page<>();
        pageInfo.setCurrent(pageNum);
        pageInfo.setSize(pageSize);

        LambdaQueryWrapper<SmsCoupon> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(name),SmsCoupon::getName,name);
        queryWrapper.eq(SmsCoupon::getType,type);

        return this.selectPage(pageInfo,queryWrapper);
    }*/

}
